import 'package:flutter/material.dart';
import 'package:ball_lion/resources/colours.dart';
import 'package:ball_lion/resources/get_icon.dart';

class CheckWidget extends StatefulWidget {
  const CheckWidget(
      {super.key, required this.value, this.onChanged, required this.size});

  final bool value;
  final double size;
  final ValueChanged<bool>? onChanged;

  @override
  State<CheckWidget> createState() => _CheckWidgetState();
}

class _CheckWidgetState extends State<CheckWidget> {
  bool get value => widget.value;
  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: () {
        widget.onChanged?.call(!value);
      },
      child: Container(
        width: widget.size,
        height: widget.size,
        decoration: BoxDecoration(
            shape: BoxShape.circle,
            color: value ? Colours.main : null,
            border:
                value ? null : Border.all(color: Colours.grey99, width: 0.5)),
        child: Icon(GetIcon.check,
            color: value ? Colours.white : Colours.transparent,
            size: widget.size),
      ),
    );
  }
}
